﻿// <copyright file="TypedCategoryEditor.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2010-05-24</date>
// <summary>Typed Category Editor class definition</summary>

namespace Microsoft.WebAnalytics.Design.Editors
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Windows.Design.PropertyEditing;

    /// <summary>
    /// Typed Category Editor
    /// </summary>
    /// <typeparam name="T">the type that this category inspects</typeparam>
    public class TypedCategoryEditor<T> : AnalyticsCategoryEditor
    { 
        /// <summary>
        /// Returns true if the declaring type is the category editor's type
        /// </summary>
        /// <param name="propertyEntry">the property entry</param>
        /// <returns>true if the editor consumes the property</returns>
        /// <exception cref="ArgumentNullException">if PropertyEntry is null</exception>
        public override bool ConsumesProperty(PropertyEntry propertyEntry)
        {
            if (propertyEntry == null)
            {
                throw new ArgumentNullException("propertyEntry");
            }

            bool consumes = false;

            if (propertyEntry.Identifier.DeclaringType == typeof(T))
            {
                consumes = true;
            }

            return consumes;
        }
    }
}
